#include "TextBuffer.h"

namespace nsfq{

CTextBuffer::CTextBuffer( char *pText, int iLength ) : m_pText( pText ), m_iLength(iLength)
{
	m_pLast = m_pText + iLength;
	m_pBegin = m_pEnd = m_pText;
}

int CTextBuffer::GetLine(string &sLine)
{
	char *pCurrent = m_pBegin;
	while( pCurrent < m_pLast )
	{
		if( *pCurrent == '\n' )
			break;

		pCurrent++;
	}

	m_pEnd = pCurrent;
	sLine = string( m_pBegin, m_pEnd - m_pBegin );
	m_pBegin = pCurrent + 1;
	return sLine.size();
}

};
